package com.cloud;

import io.modelcontextprotocol.client.McpClient;
import io.modelcontextprotocol.client.McpSyncClient;
import io.modelcontextprotocol.client.transport.ServerParameters;
import io.modelcontextprotocol.client.transport.StdioClientTransport;
import io.modelcontextprotocol.spec.McpClientTransport;
import io.modelcontextprotocol.spec.McpSchema;
import io.modelcontextprotocol.spec.McpTransport;

import java.time.Duration;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {
        HashMap<String, String> envMap = new HashMap<>();
        envMap.put("GITHUB_PERSONAL_ACCESS_TOKEN", "-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");
        ServerParameters params = ServerParameters.builder("npx")
                .args("-y", "@modelcontextprotocol/server-github")
                .env(envMap)
                .build();
        McpTransport transport = new StdioClientTransport(params);
        // Create a sync client with custom configuration
        McpSyncClient client = McpClient.sync((McpClientTransport) transport)
                .build();

// Initialize connection
        client.initialize();

// List available tools
        McpSchema.ListToolsResult tools = client.listTools();
        System.out.println(tools);
// Close client
        client.closeGracefully();
    }
}
